package cn.tedu.csmall.server.pojo.dto;

import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Objects;

import static cn.tedu.csmall.server.pojo.validation.BrandValidation.*;

/**
 * @author lixin
 * @Date 2022/8/27
 */
//实现序列化接口
public class BrandAddNewDTO implements Serializable {
    @NotBlank(message = "name is NotBlank")//不允许为空白（字符串长度可能大于0，却是由空格，tab空白输入）
    @NotEmpty(message = "name is NotEmpty")//不允许为空字符串
    @NotNull(message = "name is NotNull")//不允许为null
    @ApiModelProperty(value = "名称", required = true, example = "华为")
    private String name;//名称
    @NotBlank(message = "pinyin不能为空")
    @Pattern(regexp = REGEXP_PINYIN, message = MESSAGE_PINYIN)
    @ApiModelProperty(value = "拼音", required = true, example = "huawei")
    private String pinyin;//拼音
    @ApiModelProperty(value = "LOGO图片", required = true, example = "https://cdn.tmooc.cn/image1.png")
    private String logo;//LOGO图片
    @ApiModelProperty(value = "类别id", required = true, example = "1")
    private Long categoryId;//类别id
    @ApiModelProperty(value = "简介", example = "xxxx")
    private String description;//简介
    @ApiModelProperty(value = "关键字", example = "华为")
    private String keywords;//关键字
    @Range(max = 99, message = "sort范围必须为0-99")
    @ApiModelProperty(value = "排序值", example = "1")
    private Integer sort;//排序值

    @Override
    public String toString() {
        return "BrandAddNewDTO{" +
                "name='" + name + '\'' +
                ", pinyin='" + pinyin + '\'' +
                ", logo='" + logo + '\'' +
                ", categoryId=" + categoryId +
                ", description='" + description + '\'' +
                ", keywords='" + keywords + '\'' +
                ", sort=" + sort +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        BrandAddNewDTO that = (BrandAddNewDTO) o;
        return Objects.equals(name, that.name) &&
                Objects.equals(pinyin, that.pinyin) &&
                Objects.equals(logo, that.logo) &&
                Objects.equals(categoryId, that.categoryId) &&
                Objects.equals(description, that.description) &&
                Objects.equals(keywords, that.keywords) &&
                Objects.equals(sort, that.sort);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, pinyin, logo, categoryId, description, keywords, sort);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPinyin() {
        return pinyin;
    }

    public void setPinyin(String pinyin) {
        this.pinyin = pinyin;
    }

    public String getLogo() {
        return logo;
    }

    public void setLogo(String logo) {
        this.logo = logo;
    }

    public Long getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Long categoryId) {
        this.categoryId = categoryId;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getKeywords() {
        return keywords;
    }

    public void setKeywords(String keywords) {
        this.keywords = keywords;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }
}
